﻿@using Orchard.Utility.Extensions
@using Vandelay.Industries.Models
@{
    var sortOrders = Model.CustomSorts as IEnumerable<CustomSortRecord>;
    var pager = Model.Pager;
    var pageSizes = new List<int?> { 10, 50, 100 };
    var defaultPageSize = WorkContext.CurrentSite.PageSize;
    if (!pageSizes.Contains(defaultPageSize)) {
        pageSizes.Add(defaultPageSize);
    }
    var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
}

<h1>@Html.TitleForPage(T("Manage Custom Sort Orders").Text) </h1>
@using (Html.BeginFormAntiForgeryPost()) {
    @Html.ValidationSummary()
    <div class="manage">
        @Html.ActionLink(
            T("Add a new custom sort order").Text,
            "Create", "CustomSortAdmin",
            null,
            new { @class = "button primaryAction" })
    </div>

    <fieldset>
        <table class="items">
            <thead>
                <tr>
                    <th scope="col">@T("Name")</th>
                    <th scope="col" class="actions">&nbsp;</th>
                </tr>
            </thead>
            @foreach (var sortOrder in sortOrders) {
                <tr>
                    <td>
                        @Html.ActionLink(sortOrder.Name, "Edit", "CustomSortAdmin", new {returnUrl, sortOrder.Id}, null)
                    </td>
                    <td>
                        @Html.ActionLink(T("Delete").Text, "Delete", "CustomSortAdmin", new { returnUrl, sortOrder.Id }, new { itemprop = "RemoveUrl UnsafeUrl" })
                    </td>
                </tr>
            }
        </table>
        @Display(pager)
    </fieldset>
}